#!/bin/bash
#                out_of_order.sh2                          2014-08-03 Agner Fog
#
# PMC Test program for measuring out-of-order capacity
#
# (c) 2014 GNU General Public License www.gnu.org/licenses

# Test cases:
# 1: integer add
# 2: integer mul
# 3: floating point add
# 4: floating point mul

. vars.sh

echo -e "Test out-of-order execution capacity"  > results2/out_of_order.txt

for tcase in {1..4}
do

for chainlength in 10 100 1000 1000000
do

if [ $tcase -eq 1 ]; then echo -e "\n\nCase 1: integer add, chainlength = $chainlength" >> results2/out_of_order.txt ; fi
if [ $tcase -eq 2 ]; then echo -e "\n\nCase 2: integer mul, chainlength = $chainlength" >> results2/out_of_order.txt ; fi
if [ $tcase -eq 3 ]; then echo -e "\n\nCase 3: floating point add, chainlength = $chainlength" >> results2/out_of_order.txt ; fi
if [ $tcase -eq 4 ]; then echo -e "\n\nCase 4: floating point mul, chainlength = $chainlength" >> results2/out_of_order.txt ; fi

$ass -f elf64 -o b64.o -Dtcase=$tcase -Dchainlength=$chainlength -Dnthreads=1 -Pout_of_order.inc TemplateB64.nasm
if [ $? -ne 0 ] ; then exit ; fi
g++ -m64 a64.o b64.o -ox -lpthread
if [ $? -ne 0 ] ; then exit ; fi
./x >> results2/out_of_order.txt

done
done

echo -e "\n"  >> results2/out_of_order.txt
